package cn.stylefeng.guns.sys.modular.system.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.core.properties.GzhConfig;
import cn.stylefeng.guns.sys.core.util.DateUtil;
import cn.stylefeng.guns.sys.modular.system.entity.*;
import cn.stylefeng.guns.sys.modular.system.mapper.*;
import cn.stylefeng.guns.sys.modular.system.model.params.ProjectParam;
import cn.stylefeng.guns.sys.modular.system.service.*;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import javax.annotation.Resource;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class GcAppServiceImpl extends ServiceImpl<GcgMsgMapper, GcgMsg> implements GcAppService {

    private static Logger logger = LoggerFactory.getLogger(GcAppServiceImpl.class);

    @Resource
    private TaskMapper taskMapper;
    @Resource
    private WeChatSendTempMsgService weChatSendTempMsgService;
    @Resource
    private ProjectService projectService;
    @Resource
    private BtyWxMapper btyWxMapper;
    @Resource
    private GzhConfig gzhConfig;
    @Resource
    private ProjectMapper projectMapper;
    @Resource
    private TaskService taskService;
    @Resource
    private UserService userService;
    @Resource
    private TaskFlowMapper taskFlowMapper;
    @Resource
    private UserMapper userMapper;

    // 跳转URL
    private String path = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=";
    private String type = "&response_type=code";
    private String scope = "&scope=snsapi_userinfo";
    private String state = "&state=STATE#wechat_redirect";


    /**
     * 本店任务列表
     * @param proId
     * @return
     */
    @Override
    public ResponseData proIdList(Integer proId) {

//        //根据phone查询当前登陆者角色
//        String roleIds = null;
//        Map roleMap = btyWxMapper.getRole(account);
//        if (roleMap != null && roleMap.size() != 0) {
//            roleIds = roleMap.get("roleId").toString();//获取当前登录者角色
//        }
//        int status = 0;//0不是该店督导，1是督导
//        //查询该店督导电话
//        String ddTel = this.baseMapper.getDdTel(proId);
//
//        //既是营运经理又是督导
//        if (roleIds.contains("1308249608428101633") && roleIds.contains("1283292980305018882")) {
//            //是该店督导
//            if (ddTel.equals(account)) {
//                status = 1;
//            } else {
//                status = 0;
//            }
//            //是营运经理不是督导
//        } else if (roleIds.contains("1308249608428101633") && !roleIds.contains("1283292980305018882")) {
//            status = 0;
//            //是督导不是营运经理
//        } else if (roleIds.contains("1283292980305018882") && !roleIds.contains("1308249608428101633")) {
//            status = 1;
//        }

        //本店任务列表
        List<Map> list = this.baseMapper.proIdList(proId);
        String proName = this.baseMapper.getProName(proId);
        String dd = this.baseMapper.getDdTel(proId);
        List<Map> objects = new ArrayList<>();

        //objects存储已完成数据
        for (Map map : list) {

            if (ToolUtil.isEmpty(map.get("proName"))){
                map.put("proName", proName);
            }

            if (ToolUtil.isEmpty(map.get("dd"))){
                map.put("dd", dd);
            }

            if (((int) map.get("id") == 36 || (int) map.get("id") == 37 || (int) map.get("id") == 38) && map.get("sta").equals("已完成")) {
                objects.add(map);
            }
        }

        Map map = new HashMap<>();
        map.put("name", "网上建店");
        map.put("id", 36);
        map.put("proName", proName);
        map.put("proId", proId);
        map.put("status",0);
        map.put("sta","未完成");
        map.put("dd", dd);


        //如果三个都完成，则完成
        //任意一个未完成，则未完成
        if (objects.size() != 3) {

            list.removeAll(objects);
            list.add(map);
        }

        return ResponseData.success(list);
    }


    /**
     * 新增任务信息
     *
     * @param taskStatus
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int addRent(List<TaskStatus> taskStatus) throws ParseException {

        logger.info("==========" + taskStatus);

        //修改状态,所有修改操作数据库新增条数必须都大于0才会提交事务
        StringBuilder result = new StringBuilder();
        // 数据库修改条数
        int count = 0;

        if (ToolUtil.isNotEmpty(taskStatus)) {

            //任务状态
            List<TaskStatus> taskStatuses = new ArrayList<>();
            //任务流水
            List<TaskFlow> taskFlows = new ArrayList<>();
            //消息管理
            List<GcgMsg> gcgMsgs = new ArrayList<>();

            for (TaskStatus status : taskStatus) {

                //填写内容为固定项
                if (status.getTaskId() != null) {

                    //获取当前用户userId
                    Long userId = userMapper.getUserId(status.getCreateId().toString());//CreateId为用户电话

                    int msg = taskMapper.getRent(status.getProId(), status.getTaskId());

                    //之前没有填写过信息
                    if (msg == 0) {

                        if (status.getStatus() == null) {
                            status.setStatus(1);//提交信息
                        }

                        //不是可乐机新增，不是到货日期
                        if (status.getTaskId() != 19 && status.getTaskId() != 15) {
                            taskStatuses.add(status);
                            //是可乐机修改状态
                        } else if (status.getTaskId() == 19) {
                            taskMapper.updateStatus(status);
                        }

                        //流程明细表
                        TaskFlow taskFlow = new TaskFlow();
                        taskFlow.setProId(status.getProId());
                        taskFlow.setTaskId(status.getTaskId());

                        if (status.getTaskName() != null || status.getTaskName() != "") {
                            taskFlow.setTaskName(status.getTaskName());
                        }

                        taskFlow.setCreateUser(userId);
                        taskFlow.setCreateTime(new Date());

                        //不是到货日期
                        if (status.getTaskId() != 15){
                            if (status.getStatus() != null) {
                                taskFlow.setStatus(status.getStatus());
                            } else {
                                taskFlow.setStatus(1);
                            }
                            //到货日期
                        }else {
                            taskFlow.setStatus(0);
                        }

                        taskFlows.add(taskFlow);

                        //查询店名
                        String dm = taskMapper.selectDm(status.getProId());
                        //任务名称
                        String taskName = taskMapper.getName(status.getTaskId());

                        //可乐机
                        if (status.getTaskId() == 19) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);


                            //通知督导
                            String now = DateUtil.getNow();//当前时间
                            String data = dm + "可乐机已确认";
                            JSONObject tempObj = weChatSendTempMsgService.setTempParam(dm, null, "可乐机已确认", "可乐机已确认", now, data);

                            //推送督导可乐机已确认消息
                            Map<String, String> openidMap = projectService.selectDd(status.getProId());
                            //督导
                            String dd = openidMap.get("dd");
                            //督导id
                            User user = btyWxMapper.selectUser(dd);
                            String[] openid = new String[]{user.getOpenid()};

                            //可乐机url（督导）
                            String kljUrl = BusConst.KLJDDURL + "&proId=" + status.getProId() + "&taskId=" + status.getTaskId() + "&userId=" + user.getUserId();
                            String url = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(kljUrl) + type + scope + state;

                            //推送督导消息
                            weChatSendTempMsgService.sendmsg(openid, url, tempObj);
                            logger.info("======已推送督导可乐机已确认消息======");

                            //消息表中新增收可乐机消息
                            GcgMsg gcgMsg2 = new GcgMsg();
                            gcgMsg2.setBusinessId(status.getProId());//业务id
                            gcgMsg2.setBusinessType("工程");//业务类型
                            gcgMsg2.setBusinessName(dm);//业务名称
                            gcgMsg2.setTaskId(status.getTaskId());//任务id
                            gcgMsg2.setMsgType("可乐机已确认");//消息类型
                            gcgMsg2.setMessage(data);//消息内容
                            gcgMsg2.setPath(url);//跳转路径
                            gcgMsg2.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg2.setSendUser(userId);//发送人id
                            gcgMsg2.setReceiveUser(user.getUserId());//接收人ID
                            gcgMsg2.setCreateTime(new Date());//创建时间

                            //消息表新增可乐机已确认消息
                            this.baseMapper.insert(gcgMsg2);


                            //股份未交齐
                        } else if (status.getTaskId() == 18) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            //网上建店
                        } else if (status.getTaskId() == 36) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            //线上套餐
                        } else if (status.getTaskId() == 37) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            //排队机
                        } else if (status.getTaskId() == 38) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            //当地供货商
                        } else if (status.getTaskId() == 17) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            //宿舍信息
                        } else if (status.getTaskId() == 23) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            //卫生许可证
                        } else if (status.getTaskId() == 13) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);
                        }

                        //确定工程开业日期
                        else if (status.getTaskId() == 16) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                            Date toDate = sdf.parse(status.getContent());//开业日期

                            //工程表
                            ProjectParam projectParam = new ProjectParam();
                            projectParam.setOpenDate(toDate);//开业日期
                            projectParam.setId(status.getProId());

                            //修改工程开业时间
                            projectMapper.updateProjectByCondition(projectParam);
                            logger.info("===========工程表已添加开业时间========");

                            //收银系统负责人 (刘书伟)
                            String syxt = BusConst.LSW;
                            String[] openids = new String[]{syxt};

                            //收银系统负责人 (刘书伟)id
                            User user = btyWxMapper.selectUser(syxt);
                            Map<String, String> openidMap = projectService.selectDd(status.getProId());

                            String ddName = openidMap.get("ddName");
                            String ddTel = openidMap.get("ddTel");

                            //推送收银系统确认消息
                            String data = dm + "已确定开业日期为: " + status.getContent() + ",请确认收银系统。该店督导为：" + ddName + "电话为: " + ddTel;
                            logger.info("==========开业时间已确认========");

                            JSONObject tempObj = weChatSendTempMsgService.setTempParam(dm, null, "确认收银系统", "收银系统", DateUtil.getNow(), data);

                            if (ToolUtil.isNotEmpty(user)){
                                //收银系统url(负责人)
                                String syUrl = BusConst.SYURL + "&proId=" + status.getProId() + "&taskId=21" + "&userId=" + user.getUserId();
                                String url = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(syUrl) + type + scope + state;

                                //推送收银系统消息
                                weChatSendTempMsgService.sendmsg(openids, url, tempObj);
                                logger.info("===========推送收银系统负责人消息==========");

                                //消息表中新增收银系统消息
                                GcgMsg gcgMsg1 = new GcgMsg();
                                gcgMsg1.setBusinessId(status.getProId());//业务id
                                gcgMsg1.setBusinessType("工程");//业务类型
                                gcgMsg1.setBusinessName(dm);//业务名称
                                gcgMsg1.setTaskId(21);//任务id
                                gcgMsg1.setMsgType("确认收银系统提醒");//消息类型
                                gcgMsg1.setMessage(data);//消息内容
                                gcgMsg1.setPath(url);//跳转路径
                                gcgMsg1.setTaskStatus(1);//任务状态;0->已完成，1->未完成
                                gcgMsg1.setSendUser(userId);//发送人id
                                gcgMsg1.setReceiveUser(user.getUserId());//接收人ID
                                gcgMsg1.setCreateTime(new Date());//创建时间

                                //消息表新增收银系统数据
                                this.baseMapper.insert(gcgMsg1);
                            }

                            String data1 = dm + "已确定开业日期:" + status.getContent() + "。该店督导为：" + ddName + "电话为: " + ddTel;
                            JSONObject tempObj1 = weChatSendTempMsgService.setTempParam(dm, null, "确认开业日期", "开业日期", DateUtil.getNow(), data1);

                            //设计总监(朱小平)
                            String sjzj = BusConst.SJZJ;
                            String[] openids1 = new String[]{sjzj};
                            //设计总监(朱小平)id
                            User user1 = btyWxMapper.selectUser(sjzj);

                            if (ToolUtil.isNotEmpty(user1)){

                                //确定开业时间url(已确认)
                                String kyUrl = BusConst.KYURL + "&proId=" + status.getProId() + "&taskId=" + status.getTaskId() + "&userId=" + user1.getUserId();
                                String url1 = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(kyUrl) + type + scope + state;

                                //推送设计总监消息
                                weChatSendTempMsgService.sendmsg(openids1, url1, tempObj1);
                                logger.info("========推送设计总监消息==========");

                                //消息表中新增确认开业时间消息
                                GcgMsg gcgMsg2 = new GcgMsg();
                                gcgMsg2.setBusinessId(status.getProId());//业务id
                                gcgMsg2.setBusinessType("工程");//业务类型
                                gcgMsg2.setBusinessName(dm);//业务名称
                                gcgMsg2.setTaskId(16);//任务id
                                gcgMsg2.setMsgType("已确认开业日期提醒");//消息类型
                                gcgMsg2.setMessage(data1);//消息内容
                                gcgMsg2.setPath(url1);//跳转路径
                                gcgMsg2.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                                gcgMsg2.setSendUser(userId);//发送人id
                                gcgMsg2.setReceiveUser(user1.getUserId());//接收人ID
                                gcgMsg2.setCreateTime(new Date());//创建时间

                                //消息表新增开业日期提醒
                                this.baseMapper.insert(gcgMsg2);
                            }

                            //丁玲
                            String dl = BusConst.DL;
                            String[] openid = new String[]{dl};
                            //丁玲id
                            User userDl = btyWxMapper.selectUser(dl);

                            if (ToolUtil.isNotEmpty(userDl)){
                                //推送丁玲消息
                                weChatSendTempMsgService.sendmsg(openid, BusConst.MSURL, tempObj1);
                                logger.info("=======推送丁玲消息==========");

                                //消息表中新增确认开业时间消息
                                GcgMsg msg1 = new GcgMsg();
                                msg1.setBusinessId(status.getProId());//业务id
                                msg1.setBusinessType("工程");//业务类型
                                msg1.setBusinessName(dm);//业务名称
                                msg1.setTaskId(status.getTaskId());//任务id
                                msg1.setMsgType("已确认开业日期提醒");//消息类型
                                msg1.setMessage(data1);//消息内容
                                msg1.setPath(BusConst.MSURL);//跳转路径
                                msg1.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                                msg1.setSendUser(userId);//发送人id
                                msg1.setReceiveUser(userDl.getUserId());//接收人ID
                                msg1.setCreateTime(new Date());//创建时间

                                //消息表新增收确认开业时间消息
                                this.baseMapper.insert(msg1);
                            }

                            //确认收银系统
                        } else if (status.getTaskId() == 21) {

                            if (status.getContent().equals("收银账号已建完，收银档案未建完")) {

                                GcgMsg gcgMsg = new GcgMsg();
                                gcgMsg.setBusinessId(status.getProId());//业务id
                                gcgMsg.setTaskId(status.getTaskId());//任务id
                                gcgMsg.setTaskStatus(1);//任务状态;0->已完成，1->未完成
                                gcgMsg.setEndTime(new Date());//任务完成时间

                                gcgMsgs.add(gcgMsg);

                                taskService.addTxl(status.getProId(), null, status.getTaskId());


                                //通知督导,韩铭渲
                                String now = DateUtil.getNow();//当前时间
                                String data = dm + "收银账号已建完";

                                JSONObject tempObj = weChatSendTempMsgService.setTempParam(dm, null, "收银账号已建完", "收银账号已建完", now, data);

                                Map<String, String> openidMap = projectService.selectDd(status.getProId());
                                //督导
                                String dd = openidMap.get("dd");

                                List list = new ArrayList();
                                list.add(dd);

                                //接收消息人id
                                List<User> userList = btyWxMapper.getUser(list);
                                if (ToolUtil.isNotEmpty(userList)) {
                                    for (User user : userList) {

                                        //收银系统url(督导)
                                        String syUrl = BusConst.SYDDURL + "&proId=" + status.getProId() + "&taskId=" + status.getTaskId() + "&userId=" + user.getUserId();
                                        String url = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(syUrl) + type + scope + state;

                                        String[] openids = new String[]{user.getOpenid()};

                                        //推送消息
                                        weChatSendTempMsgService.sendmsg(openids, url, tempObj);
                                        logger.info("======已推送督导收银账号已建完消息======");


                                        //消息表中新增收银系统消息
                                        GcgMsg gcgMsg1 = new GcgMsg();
                                        gcgMsg1.setBusinessId(status.getProId());//业务id
                                        gcgMsg1.setBusinessType("工程");//业务类型
                                        gcgMsg1.setBusinessName(dm);//业务名称
                                        gcgMsg1.setTaskId(status.getTaskId());//任务id
                                        gcgMsg1.setMsgType("收银账号已建完");//消息类型
                                        gcgMsg1.setMessage(data);//消息内容
                                        gcgMsg1.setPath(url);//跳转路径
                                        gcgMsg1.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                                        gcgMsg1.setSendUser(userId);//发送人id
                                        gcgMsg1.setReceiveUser(user.getUserId());//接收人ID
                                        gcgMsg1.setCreateTime(new Date());//创建时间

                                        //消息表新增收银系统消息
                                        this.baseMapper.insert(gcgMsg1);
                                    }
                                }

                                //收银档案负责人（韩铭渲）
                                String sy = BusConst.HMX;
                                String[] openid = new String[]{sy};
                                User user1 = btyWxMapper.selectUser(sy);

                                if (ToolUtil.isNotEmpty(user1)){
                                    //收银档案负责人url
                                    String syUrl = BusConst.DAURL + "&proId=" + status.getProId() + "&taskId=" + status.getTaskId() + "&userId=" + user1.getUserId();
                                    String url1 = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(syUrl) + type + scope + state;

                                    //推送收银档案负责人消息
                                    weChatSendTempMsgService.sendmsg(openid, url1, tempObj);
                                    logger.info("======已推送收银档案负责人收银账号已建完消息======");

                                    //消息表中新增收银系统消息
                                    GcgMsg gcgMsg2 = new GcgMsg();
                                    gcgMsg2.setBusinessId(status.getProId());//业务id
                                    gcgMsg2.setBusinessType("工程");//业务类型
                                    gcgMsg2.setBusinessName(dm);//业务名称
                                    gcgMsg2.setTaskId(status.getTaskId());//任务id
                                    gcgMsg2.setMsgType("收银账号已建完");//消息类型
                                    gcgMsg2.setMessage(data);//消息内容
                                    gcgMsg2.setPath(url1);//跳转路径
                                    gcgMsg2.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                                    gcgMsg2.setSendUser(userId);//发送人id
                                    gcgMsg2.setReceiveUser(user1.getUserId());//接收人ID
                                    gcgMsg2.setCreateTime(new Date());//创建时间

                                    //消息表新增收银系统消息
                                    this.baseMapper.insert(gcgMsg2);
                                }

                            }

                        }
                        //卫生许可证
                        else if (status.getTaskId() == 44) {

                            taskService.addTxl(status.getProId(), status.getContent(), status.getTaskId());

                        }
                        //上传营业执照
                        else if (status.getTaskId() == 11) {

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);


                            TaskStatus status1 = new TaskStatus();
                            //可乐机报备
                            status1.setTaskId(19);
                            status1.setProId(status.getProId());
                            status1.setStatus(0);
                            status1.setTaskName("可乐机");
                            status1.setContent("可乐机已报备");
                            status1.setCreateId(userId);

                            taskStatuses.add(status1);

                            //流程明细表
                            TaskFlow taskFlow1 = new TaskFlow();
                            taskFlow1.setProId(status.getProId());
                            taskFlow1.setTaskId(19);
                            taskFlow1.setStatus(0);//1提交；0驳回
                            taskFlow1.setTaskName("可乐机");
                            taskFlow1.setCreateUser(userId);
                            taskFlow1.setCreateTime(new Date());

                            taskFlows.add(taskFlow1);

                            //通知可乐机负责人
                            String now = DateUtil.getNow();//当前时间
                            String data = dm + "应入可乐机";

                            JSONObject tempObj = weChatSendTempMsgService.setTempParam(dm, null, "可乐机状态", "可乐机", now, data);

                            Long role = 1314488482857709570L;//可乐机负责人
                            List<String> openidlist = userService.listOpenidsByRole(role);

                            if (ToolUtil.isNotEmpty(openidlist)){
                                logger.info("=========可乐机负责人:" + openidlist + "========");

                                //可乐机负责人id
                                List<User> user1 = btyWxMapper.getUser(openidlist);

                                if (ToolUtil.isNotEmpty(user1)) {
                                    for (User user : user1) {

                                        //可乐机url
                                        String kljUrl = BusConst.KLJURL + "&proId=" + status.getProId() + "&taskId=19" + "&userId=" + user.getUserId();
                                        String url = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(kljUrl) + type + scope + state;

                                        String[] openids = new String[]{user.getOpenid()};

                                        //推送消息
                                        weChatSendTempMsgService.sendmsg(openids, url, tempObj);
                                        logger.info("======已推送可乐机负责人消息======");


                                        //消息表中新增应入可乐机消息
                                        GcgMsg gcgMsg2 = new GcgMsg();
                                        gcgMsg2.setBusinessId(status.getProId());//业务id
                                        gcgMsg2.setBusinessType("工程");//业务类型
                                        gcgMsg2.setBusinessName(dm);//业务名称
                                        gcgMsg2.setTaskId(19);//任务id
                                        gcgMsg2.setMsgType("应入可乐机提醒");//消息类型
                                        gcgMsg2.setMessage(data);//消息内容
                                        gcgMsg2.setPath(url);//跳转路径
                                        gcgMsg2.setTaskStatus(1);//任务状态;0->已完成，1->未完成
                                        gcgMsg2.setSendUser(userId);//发送人id
                                        gcgMsg2.setReceiveUser(user.getUserId());//接收人ID
                                        gcgMsg2.setCreateTime(new Date());//创建时间

                                        //消息表新增可乐机消息
                                        this.baseMapper.insert(gcgMsg2);
                                    }
                                }
                            }

                            //刘书伟
                            String syxt = BusConst.LSW;
                            String[] openids = new String[]{syxt};
                            //收银系统负责人 (刘书伟)id
                            User user = btyWxMapper.selectUser(syxt);
                            Map<String, String> openidMap = projectService.selectDd(status.getProId());

                            String ddName = openidMap.get("ddName");
                            String ddTel = openidMap.get("ddTel");

                            //推送收银系统确认消息
                            String data1 = dm + "已填写营业执照信息，请确认收银系统。该店督导为：" + ddName + "电话为: " + ddTel;
                            logger.info("==========已填写营业执照信息========");

                            JSONObject tempObj1 = weChatSendTempMsgService.setTempParam(dm, null, "确认收银系统", "收银系统", DateUtil.getNow(), data1);

                            if (ToolUtil.isNotEmpty(user)){
                                //收银系统url(负责人)
                                String syUrl = BusConst.SYURL + "&proId=" + status.getProId() + "&taskId=21" + "&userId=" + user.getUserId();
                                String url = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(syUrl) + type + scope + state;

                                //推送收银系统消息
                                weChatSendTempMsgService.sendmsg(openids, url, tempObj1);
                                logger.info("===========推送收银系统负责人消息==========");

                                //消息表中新增收银系统消息
                                GcgMsg gcgMsg1 = new GcgMsg();
                                gcgMsg1.setBusinessId(status.getProId());//业务id
                                gcgMsg1.setBusinessType("工程");//业务类型
                                gcgMsg1.setBusinessName(dm);//业务名称
                                gcgMsg1.setTaskId(21);//任务id
                                gcgMsg1.setMsgType("确认收银系统提醒");//消息类型
                                gcgMsg1.setMessage(data);//消息内容
                                gcgMsg1.setPath(url);//跳转路径
                                gcgMsg1.setTaskStatus(1);//任务状态;0->已完成，1->未完成
                                gcgMsg1.setSendUser(userId);//发送人id
                                gcgMsg1.setReceiveUser(user.getUserId());//接收人ID
                                gcgMsg1.setCreateTime(new Date());//创建时间

                                //消息表新增收银系统数据
                                this.baseMapper.insert(gcgMsg1);
                            }

                            //配送要货完成
                        } else if (status.getTaskId() == 15) {

                            status.setStatus(0);//待发货
                            taskStatuses.add(status);

                            GcgMsg gcgMsg = new GcgMsg();
                            gcgMsg.setBusinessId(status.getProId());//业务id
                            gcgMsg.setTaskId(status.getTaskId());//任务id
                            gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                            gcgMsg.setEndTime(new Date());//任务完成时间

                            gcgMsgs.add(gcgMsg);

                            // 工程表
                            ProjectParam projectParam = new ProjectParam();
                            projectParam.setArrivalTime(status.getContent());//到货日期
                            projectParam.setId(status.getProId());
                            projectParam.setPsStatus("0");//待发货

                            //修改工程到货日期
                            projectMapper.updateProjectByCondition(projectParam);
                            logger.info("===========工程表已添加到货日期========");


                            //推送供应链消息
                            String data = dm + "已确认到货日期为" + status.getContent() + "，请尽快完成配送！";
                            logger.info("==========已完成配送========");

                            JSONObject tempObj = weChatSendTempMsgService.setTempParam(dm, null, "配送要货", "配送要货", DateUtil.getNow(), data);

//                            Long role = 1314441729702100993L;//供应链
                            Long role = 1278615893124055041L;//配送管理
                            List<String> list = userService.listOpenidsByRole(role);

                            if (ToolUtil.isNotEmpty(list)){
                                logger.info("=========配送管理:" + list + "========");

                                String[] openids = list.toArray(new String[list.size()]);
                                //推送消息
                                weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                                logger.info("======推送配送管理消息======");
                            }
                        }
                    }
                }
            }

            if (taskStatuses.size() != 0) {
                //新增信息
                count = taskMapper.addRentList(taskStatuses);
                result.append(count > 0 ? 1 : 0);
            }

            if (taskFlows.size() != 0) {
                //新增流程明细表
                count = taskFlowMapper.addList(taskFlows);
                result.append(count > 0 ? 1 : 0);
            }

            if (gcgMsgs.size() != 0) {
                //修改消息表
                count = this.baseMapper.updateList(gcgMsgs);
            }

        }
        if (result.indexOf("0") >= 0) {
            //事务回滚
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return 0;
        } else {
            return 1;
        }
    }


    /**
     * 收银系统建档
     * @param taskStatus
     * @return
     */
    @Override
    @Transactional
    public ResponseData archives(List<TaskStatus> taskStatus) {

        //修改状态,所有修改操作数据库新增条数必须都大于0才会提交事务
        StringBuilder result = new StringBuilder();
        // 数据库修改条数
        int count = 0;

        if (ToolUtil.isNotEmpty(taskStatus)) {

            for (TaskStatus status : taskStatus) {

                Long userId = userMapper.getUserId(status.getCreateId().toString());

                //流程明细表
                TaskFlow taskFlow = new TaskFlow();
                taskFlow.setProId(status.getProId());
                taskFlow.setTaskId(status.getTaskId());
                taskFlow.setStatus(2);//状态 1提交/确认/通过；0驳回; 2收银已建档
                if (status.getTaskName() != null || status.getTaskName() != "") {
                    taskFlow.setTaskName(status.getTaskName());
                }
                taskFlow.setCreateUser(userId);
                taskFlow.setCreateTime(new Date());

                if (status.getStatus() == null) {
                    status.setStatus(2);//状态 1提交/确认/通过；0驳回/未完成；2收银已建档
                }

                //status表修改content
                count = taskMapper.updateCon(status);
                result.append(count > 0 ? 1 : 0);

                //flow表新增数据
                count = taskFlowMapper.add(taskFlow);
                result.append(count > 0 ? 1 : 0);

                //收银系统档案已建完
                if (status.getTaskId() == 21 && status.getContent().equals("收银档案已建完")) {

                    //通知督导，设计
                    String now = DateUtil.getNow();//当前时间
                    //查询店名
                    String dm = taskMapper.selectDm(status.getProId());
                    String data = dm + "收银档案已建完";

                    JSONObject tempObj = weChatSendTempMsgService.setTempParam(dm, null, "收银档案已建完", "收银档案已建完", now, data);

                    Map<String, String> openidMap = projectService.selectDd(status.getProId());
                    //督导
                    String dd = openidMap.get("dd");

                    User user = btyWxMapper.selectUser(dd);

                    //收银系统url(督导)
                    String syUrl = BusConst.SYDDURL + "&proId=" + status.getProId() + "&taskId=" + status.getTaskId() + "&userId=" + user.getUserId();
                    String url = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(syUrl) + type + scope + state;

                    String[] openids = new String[]{user.getOpenid()};

                    //推送消息
                    weChatSendTempMsgService.sendmsg(openids, url, tempObj);
                    logger.info("======已推送督导收银档案已建完消息======");


                    //消息表中新增收银系统消息
                    GcgMsg gcgMsg1 = new GcgMsg();
                    gcgMsg1.setBusinessId(status.getProId());//业务id
                    gcgMsg1.setBusinessType("工程");//业务类型
                    gcgMsg1.setBusinessName(dm);//业务名称
                    gcgMsg1.setTaskId(status.getTaskId());//任务id
                    gcgMsg1.setMsgType("收银档案已建完");//消息类型
                    gcgMsg1.setMessage(data);//消息内容
                    gcgMsg1.setPath(url);//跳转路径
                    gcgMsg1.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                    gcgMsg1.setSendUser(userId);//发送人id
                    gcgMsg1.setReceiveUser(user.getUserId());//接收人ID
                    gcgMsg1.setCreateTime(new Date());//创建时间

                    //消息表新增收银系统消息
                    this.baseMapper.insert(gcgMsg1);


                    //设计(任召栋)
                    String sj = BusConst.SJ;
                    //设计(任召栋)
                    String[] openid = new String[]{sj};

                    //设计(任召栋)
                    User user1 = btyWxMapper.selectUser(sj);

                    if (ToolUtil.isNotEmpty(user1)){
                        //收银系统url（设计）
                        String sjUrl = BusConst.SYSJURL + "&proId=" + status.getProId() + "&taskId=" + status.getTaskId() + "&userId=" + user1.getUserId();
                        String url1 = path + gzhConfig.getAppid() + "&redirect_uri=" + URLEncoder.encode(sjUrl) + type + scope + state;

                        String ddName = openidMap.get("ddName");
                        String ddTel = openidMap.get("ddTel");
                        String data1 = dm + "收银档案已建完。请完成桌边码后联系督导：" + ddName + "，电话为:" + ddTel;
                        JSONObject tempObj1 = weChatSendTempMsgService.setTempParam(dm, null, "收银档案已建完", "收银档案已建完", now, data1);

                        //推送设计消息
                        weChatSendTempMsgService.sendmsg(openid, url1, tempObj1);
                        logger.info("======已推送设计收银档案已建完消息======");

                        //消息表中新增收银系统消息
                        GcgMsg gcgMsg2 = new GcgMsg();
                        gcgMsg2.setBusinessId(status.getProId());//业务id
                        gcgMsg2.setBusinessType("工程");//业务类型
                        gcgMsg2.setBusinessName(dm);//业务名称
                        gcgMsg2.setTaskId(status.getTaskId());//任务id
                        gcgMsg2.setMsgType("收银档案已建完");//消息类型
                        gcgMsg2.setMessage(data);//消息内容
                        gcgMsg2.setPath(url1);//跳转路径
                        gcgMsg2.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                        gcgMsg2.setSendUser(userId);//发送人id
                        gcgMsg2.setReceiveUser(user1.getUserId());//接收人ID
                        gcgMsg2.setCreateTime(new Date());//创建时间

                        //消息表新增收银系统消息
                        this.baseMapper.insert(gcgMsg2);
                    }

                    Long role = 1350308851581628418L;//技术运维
                    List<String> openidlist = userService.listOpenidsByRole(role);

                    if (ToolUtil.isNotEmpty(openidlist)){
                        logger.info("=========技术运维:" + openidlist + "========");
                        //技术运维id
                        List<User> ywUser = btyWxMapper.getUser(openidlist);

                        String data2 = dm + "收银档案已建完，请生成二维码联系设计部。";
                        JSONObject tempObj2 = weChatSendTempMsgService.setTempParam(dm, null, "收银档案已建完", "收银档案已建完", now, data2);

                        if (ToolUtil.isNotEmpty(ywUser)) {
                            for (User yw : ywUser) {

                                String[] ywOpenid = new String[]{yw.getOpenid()};

                                //推送消息
                                weChatSendTempMsgService.sendmsg(ywOpenid, null, tempObj2);
                                logger.info("======已推送技术运维消息======");

                                //消息表中新增收银档案已建完消息
                                GcgMsg gcgMsg = new GcgMsg();
                                gcgMsg.setBusinessId(status.getProId());//业务id
                                gcgMsg.setBusinessType("工程");//业务类型
                                gcgMsg.setBusinessName(dm);//业务名称
                                gcgMsg.setTaskId(status.getTaskId());//任务id
                                gcgMsg.setMsgType("收银档案已建完");//消息类型
                                gcgMsg.setMessage(data);//消息内容
                                gcgMsg.setTaskStatus(0);//任务状态;0->已完成，1->未完成
                                gcgMsg.setSendUser(userId);//发送人id
                                gcgMsg.setReceiveUser(yw.getUserId());//接收人ID
                                gcgMsg.setCreateTime(new Date());//创建时间

                                //消息表新增收银档案已建完消息
                                this.baseMapper.insert(gcgMsg);
                            }
                        }
                    }
                }

            }
        }
        if (result.indexOf("0") >= 0) {
            //事务回滚
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return ResponseData.error("修改失败");
        } else {
            return ResponseData.success();
        }

    }

    /**
     * 全部店已完成任务列表
     *
     * @return
     */
    @Override
    public ResponseData finishShop(String account, String proName) {

        List<Map> list = new ArrayList<>();

        //查询当前登录者是否记录有电话
//        String phone = null;

        if (account != null && !"".equals(account)) {
            //根据phone查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                String roleIds = map.get("roleId").toString();//获取当前登录者角色

                //营运总监
                if (roleIds.contains("1305422678196678657") || roleIds.equals("1")) {
                    //查看全部店已完成任务
                    list = this.baseMapper.yyzjFinish(proName);
                    return ResponseData.success(list);

                    //营运经理
                } else if (roleIds.contains("1308249608428101633")) {
                    //营运经理查看自己店面下所有已完成任务
                    list = this.baseMapper.yyjlFfinish(account, proName);
                    return ResponseData.success(list);

                    //督导
                } else if (roleIds.contains("1283292980305018882")) {
                    //督导查看自己店面下所有已完成任务
                    list = this.baseMapper.ddFinish(account, proName);
                    return ResponseData.success(list);

                    //系统负责人(收银系统负责人)
                } else if (roleIds.contains("1310462425628737538")) {
                    //收银系统已完成
                    list = this.baseMapper.sjFinish(proName);
                    return ResponseData.success(list);

                    //可乐机负责人
                } else if (roleIds.contains("1314488482857709570")) {
                    //可乐机已完成
                    list = this.baseMapper.kljFinish(proName);
                    return ResponseData.success(list);

                    //网上建店负责人
                } else if (roleIds.contains("1307580056085250050")) {
                    //网上建店已完成
                    list = this.baseMapper.wsjdFinish(proName);
                    return ResponseData.success(list);

                    //设计、收银档案负责人
                } else if (roleIds.contains("1352167937466048514") || roleIds.contains("1370241296749101057")) {
                    //收银档案已完成
                    list = this.baseMapper.sydaFinish(proName);
                    return ResponseData.success(list);

                }
            }
        }
        return null;
    }


    /**
     * 全部店未完成任务列表
     *
     * @return
     */
    @Override
    public List noFinishShop(String account, String proName) {

        List list = new ArrayList<>();

        //查询当前登录者是否记录有电话
//        String phone = null;

        if (account != null && !"".equals(account)) {
            //根据wxOpenId查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                String roleIds = map.get("roleId").toString();//获取当前登录者角色

                //营运总监
                if (roleIds.contains("1305422678196678657") || roleIds.equals("1")) {
                    //查看全部店未完成任务
                    list = this.baseMapper.yyzjNoFinish(proName);

                    //营运经理
                } else if (roleIds.contains("1308249608428101633")) {
                    //营运经理查看自己店面下所有未完成任务
                    list = this.baseMapper.yyjlNoFinish(account, proName);

                    //督导
                } else if (roleIds.contains("1283292980305018882")) {
                    //督导查看自己店面下所有未完成任务
                    list = this.baseMapper.ddNoFinish(account, proName);

                    //系统负责人（收银系统负责人）
                } else if (roleIds.contains("1310462425628737538")) {
                    //已指定督导，且收银系统未完成
                    list = this.baseMapper.sjNoFinish(proName);

                    //可乐机负责人
                } else if (roleIds.contains("1314488482857709570")) {
                    //已填营业执照信息，但是可乐机未完成
                    list = this.baseMapper.kljNoFinish(proName);

                    //网上建店负责人
                } else if (roleIds.contains("1307580056085250050")) {
                    //已指定督导，且网上建店未完成
                    list = this.baseMapper.wsjdNoFinish(proName);

                    //收银档案负责人
                }else if (roleIds.contains("1370241296749101057")){
                    //收银账号已建完，收银档案未建完
                    list = this.baseMapper.sydaNoFinish(proName);
                }
            }
        }
        return list;
    }

    /**
     * 查看当前任务信息
     *
     * @param proId
     * @param taskId
     */
    @Override
    public List<TaskStatus> taskList(int proId, int taskId, String account) {

        logger.info("===============" + proId + "==" + "--" + taskId + "--" + account + "==========");

        List<TaskStatus> list = new ArrayList<>();
        List taskIdList = new ArrayList<>();

        //查询当前登录者是否记录有电话
//        String phone = null;

        String roleIds = null;
        if (account != null && !"".equals(account)) {

            //根据wxOpenId查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                roleIds = map.get("roleId").toString();//获取当前登录者角色
            }
        }
        //设计、收银账号负责人查看收银系统
//        if ((roleIds.contains("1352167937466048514") || roleIds.contains("1310462425628737538")) && taskId == 21) {
//        收银账号负责人查看收银系统
        if (roleIds.contains("1310462425628737538") && taskId == 21) {
            //营业执照和开业时间
            taskIdList.add(11);
            taskIdList.add(42);
            taskIdList.add(45);
            taskIdList.add(46);
            taskIdList.add(47);
            taskIdList.add(55);
            taskIdList.add(16);
            taskIdList.add(21);


            //可乐机负责人查看可乐机
        } else if (roleIds.contains("1314488482857709570")) {

            //可乐机，营业执照和开业时间
            taskIdList.add(11);
            taskIdList.add(42);
            taskIdList.add(45);
            taskIdList.add(46);
            taskIdList.add(47);
            taskIdList.add(55);
            taskIdList.add(19);
            taskIdList.add(16);

        } else {

            //营业执照
            if (taskId == 11) {

                taskIdList.add(11);
                taskIdList.add(42);
                taskIdList.add(45);
                taskIdList.add(46);
                taskIdList.add(47);
                taskIdList.add(55);

                //宿舍信息
            } else if (taskId == 23) {

                taskIdList.add(23);
                taskIdList.add(24);
                taskIdList.add(25);
                taskIdList.add(26);
                taskIdList.add(27);
                taskIdList.add(29);

                //卫生许可证
            } else if (taskId == 13) {

                taskIdList.add(13);
                taskIdList.add(44);

                //网上建店
            } else if (taskId == 36) {

                taskIdList.add(36);
                taskIdList.add(37);
                taskIdList.add(38);

            } else {
                taskIdList.add(taskId);
            }
        }

        logger.info("]]]]]]]]]]]]]]]" + taskIdList);
        list = this.baseMapper.taskList(proId, taskIdList);

        return list;
    }


    /**
     * 判断当前任务登录人角色
     * @param proId
     * @return
     */
    @Override
    public Map roleStatus(Integer proId, String account) {

        Map<String, Object> mapList = new HashMap<>();
        String roleIds = null;

        if (account != null && !"".equals(account)) {
            //根据phone查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                roleIds = map.get("roleId").toString();//获取当前登录者角色
            }
        }

        int status = 0;//0不是该店督导，1是督导
        //查询该店督导电话
        String ddTel = this.baseMapper.getDdTel(proId);

        if(roleIds != null){
            //既是营运经理又是督导
            if (roleIds.contains("1308249608428101633") && roleIds.contains("1283292980305018882")) {
                //是该店督导
                if (ddTel.equals(account)) {
                    status = 1;
                } else {
                    status = 0;
                }
                //是营运经理不是督导
            } else if (roleIds.contains("1308249608428101633") && !roleIds.contains("1283292980305018882")) {
                status = 0;
                //是督导不是营运经理
            } else if (roleIds.contains("1283292980305018882") && !roleIds.contains("1308249608428101633")) {
                status = 1;
            }
        }

        mapList.put("status", status);
        return mapList;
    }


    /**
     * 全部店已完成任务列表
     *
     * @return
     */
    @Override
    public LayuiPageInfo finishList(String account, String proName) {

        Page pageContext = LayuiPageFactory.defaultPage();
        IPage page = null;

        if (account != null && !"".equals(account)) {
            //根据phone查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                String roleIds = map.get("roleId").toString();//获取当前登录者角色

                //营运总监
                if (roleIds.contains("1305422678196678657") || roleIds.equals("1")) {
                    //查看全部店已完成任务
                    page = this.baseMapper.yyzjFinishList(pageContext, proName);

                    //营运经理
                } else if (roleIds.contains("1308249608428101633")) {
                    //营运经理查看自己店面下所有已完成任务
                    page = this.baseMapper.yyjlFfinishList(pageContext, account, proName);

                    //督导
                } else if (roleIds.contains("1283292980305018882")) {
                    //督导查看自己店面下所有已完成任务
                    page = this.baseMapper.ddFinishList(pageContext, account, proName);

                    //系统负责人(收银系统负责人)
                } else if (roleIds.contains("1310462425628737538")) {
                    //收银系统已完成
                    page = this.baseMapper.sjFinishList(pageContext, proName);

                    //可乐机负责人
                } else if (roleIds.contains("1314488482857709570")) {
                    //可乐机已完成
                    page = this.baseMapper.kljFinishList(pageContext, proName);

                    //网上建店负责人
                } else if (roleIds.contains("1307580056085250050")) {
                    //网上建店已完成
                    page = this.baseMapper.wsjdFinishList(pageContext, proName);

                    //设计、收银档案负责人
                } else if (roleIds.contains("1352167937466048514") || roleIds.contains("1370241296749101057")) {
                    //收银档案已完成
                    page = this.baseMapper.sydaFinishList(pageContext, proName);

                }
            }
        }
        return LayuiPageFactory.createPageInfo(page);
    }

    /**
     * 全部店未完成任务列表
     *
     * @return
     */
    @Override
    public LayuiPageInfo noFinishList(String account, String proName) {

        Page pageContext = LayuiPageFactory.defaultPage();
        IPage page = null;

        if (account != null && !"".equals(account)) {
            //根据wxOpenId查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                String roleIds = map.get("roleId").toString();//获取当前登录者角色

                //营运总监
                if (roleIds.contains("1305422678196678657") || roleIds.equals("1")) {
                    //查看全部店未完成任务
                    page = this.baseMapper.yyzjNoFinishList(pageContext, proName);


                    //营运经理
                } else if (roleIds.contains("1308249608428101633")) {
                    //营运经理查看自己店面下所有未完成任务
                    page = this.baseMapper.yyjlNoFinishList(pageContext, account, proName);

                    //督导
                } else if (roleIds.contains("1283292980305018882")) {
                    //督导查看自己店面下所有未完成任务
                    page = this.baseMapper.ddNoFinishList(pageContext, account, proName);

                    //系统负责人（收银系统负责人）
                } else if (roleIds.contains("1310462425628737538")) {
                    //已指定督导，且收银系统未完成
                    page = this.baseMapper.sjNoFinishList(pageContext, proName);

                    //可乐机负责人
                } else if (roleIds.contains("1314488482857709570")) {
                    //已填营业执照信息，但是可乐机未完成
                    page = this.baseMapper.kljNoFinishList(pageContext, proName);

                    //网上建店负责人
                } else if (roleIds.contains("1307580056085250050")) {
                    //已指定督导，且网上建店未完成
                    page = this.baseMapper.wsjdNoFinishList(pageContext, proName);

                    //收银档案负责人
                }else if (roleIds.contains("1370241296749101057")){
                    //收银账号已建完，收银档案未建完
                    page = this.baseMapper.sydaNoFinishList(pageContext, proName);
                }
            }
        }
        return LayuiPageFactory.createPageInfo(page);
    }

    /**
     * 全部店任务列表
     * @param account
     * @param proName
     * @return
     */
    @Override
    public LayuiPageInfo shopList(String account, String proName) {
        Page pageContext = LayuiPageFactory.defaultPage();
        IPage page = null;

        if (account != null && !"".equals(account)) {
            //根据wxOpenId查询当前登陆者角色
            Map map = btyWxMapper.getRole(account);
            if (map != null && map.size() != 0) {
                String roleIds = map.get("roleId").toString();//获取当前登录者角色

                    //可乐机负责人
                if (roleIds.contains("1314488482857709570")) {
                    //已填营业执照信息
                    page = this.baseMapper.kljList(pageContext, proName);
                    return LayuiPageFactory.createPageInfo(page);
                    //网上建店负责人
                } else if (roleIds.contains("1307580056085250050")) {
                    //已指定督导
                    page = this.baseMapper.wsjdList(pageContext, proName);
                    return LayuiPageFactory.createPageInfo(page);
                    //收银档案负责人
                }else if (roleIds.contains("1370241296749101057")){
                    //收银账号已建完
                    page = this.baseMapper.sydaList(pageContext, proName);
                    return LayuiPageFactory.createPageInfo(page);
                }
            }
        }
        return new LayuiPageInfo();
    }

}
